<template>
  <div class="app-container">
    <h4 class="form-header h4">学员信息</h4>

    <el-form ref="student" :model="student" label-width="80px">
      <el-row>
        <el-col :span="6" :offset="2">
          <el-form-item label="学号" prop="studentCode">
            <el-input v-model="student.studentCode" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="学员姓名" prop="studentName">
            <el-input  v-model="student.studentName" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="手机号" prop="phone">
            <el-input  v-model="student.phone" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="生日" prop="birthday">
            <el-input  v-model="student.birthday" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="缴费" prop="money">
            <el-input  v-model="student.money" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="报名节数" prop="classNum">
            <el-input  v-model="student.classNum" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="剩余节数" prop="balanceNum">
            <el-input  :value="balanceNum" :readonly="true" />
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="2">
          <el-form-item label="备注" prop="remark">
            <el-input  v-model="student.remark" :readonly="true" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <h4 class="form-header h4">体能指标: 共 {{total}} 次</h4>
    <el-table v-loading="loading" ref="table" :data="strengthtestList">
      <el-table-column label="测试ID" align="center" prop="strengthTestId" />
      <el-table-column label="测试时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}.{m}.{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="身高(cm)" align="center" prop="height" />
      <el-table-column label="体重(kg)" align="center" prop="weight" />
      <el-table-column label="摸高(cm)" align="center" prop="touchHigh" />
      <el-table-column label="立定(cm)" align="center" prop="standingLeap" />
      <el-table-column label="一分钟跳绳(n)" align="center" prop="ropeSkipping" />
      <el-table-column label="双打线折回跑5趟(s)" align="center" prop="doubleRunning" />
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="pageNum"
      :limit.sync="pageSize"
      @pagination="getList"
    />

    <el-form label-width="100px">
      <el-form-item style="text-align: center;margin-left:-120px;margin-top:30px;">
        <el-button @click="close()">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { listStrengthTest, getStudent } from "@/api/puyu/student";


export default {
  name: "StudentStrengths",
  dicts: ['puyu_classes', 'puyu_stadium'],
  data() {
    return {
       // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 体能测试表格数据
      strengthtestList: [],
      pageNum: 1,
      pageSize: 10,
      // 学员信息
      student: {},
      balanceNum: 0,
    };
  },
  created() {
    const studentId = this.$route.params && this.$route.params.studentId;
    if (!studentId) {
      return;
    }
    getStudent(studentId).then((response) => {
      this.student = response.data;
      this.loading = false;
      this.balanceNum = this.student.classNum - this.student.params.studentLessonCount;
    });
    this.student.studentId = studentId;
    // 获取学员点名列表
    this.getList();
  },
  methods: {
    /** 查询学员课时点名列表 */
    getList() {
      if (!this.student.studentId) {
        return;
      }
      // this.loading = true;
      // 查询参数
      let queryParams = {
        studentId: this.student.studentId,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }
      listStrengthTest(queryParams).then((response) => {
        this.strengthtestList = response.rows;
        this.total = response.total;
        // this.loading = false;
      });
    },
    /** 关闭按钮 */
    close() {
      const obj = { path: "/puyu/student" };
      this.$tab.closeOpenPage(obj);
    },
  },
};
</script>
